package com;

import java.util.Properties;
import java.util.concurrent.ExecutionException;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.Test;

public class Kafka测试 {
	String topic = "pioTestTopic";
	@SuppressWarnings("resource")
	@Test
	public void test() throws InterruptedException, ExecutionException{
		KafkaProducer<String, String> producer ;
		Properties props = new Properties();
        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "96.90.248.213:9092");
        props.put(ConsumerConfig.CLIENT_ID_CONFIG, "test_producer");
        props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        producer = new KafkaProducer<>(props);
        
        for (Integer i = 0; i < 10; i++) {
        	 System.out.println(producer.send(new ProducerRecord<>(topic, i.toString(),"number : "+i)).get());;		
		}
      
	}
}
